﻿@using GoodMan.Infrastructure.Entities.Entity;
@{
    ViewBag.Title = "商户信息编辑";
    Layout = "~/Areas/WorkSpace/Views/Shared/_CollegeAdminTemplete.cshtml";
    Business bModel = ViewBag.BusinessModel;
}


@section head{
    <style type="text/css">
        .nav .active
        {
            /*background: url(<?php echo $this->img('manage_r2_c13.jpg');?>) no-repeat;*/
            background-color: #F5F5F5;
        }
        .nav .other
        {
            /* background: url(<?php echo $this->img('manage_r2_c14.jpg');?>) no-repeat;*/
            background-color: #E9E9E9;
        }
        h2.nav
        {
            border-bottom: 1px solid #B4C9C6;
            font-size: 13px;
            height: 25px;
            line-height: 25px;
            margin-top: 0px;
            margin-bottom: 0px;
        }
        h2.nav a
        {
            color: #999999;
            display: block;
            float: left;
            height: 24px;
            width: 113px;
            text-align: center;
            margin-right: 1px;
            margin-left: 1px;
            cursor: pointer;
        }
    </style>
}
<div id="content-header">
    <h1>
        商户信息编辑</h1>
</div>
<div id="breadcrumb">
    <a href="#" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>首页</a>
    <a href="#" class="tip-bottom">商户管理</a> <a href="/workspace/collegeadmin/BusinessInfoList"
        class="current">商户信息</a> <a href="#" class="current">编辑</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box">
                <div class="widget-title">
                    <span class="icon"><i class="icon-align-justify"></i></span>
                    <h5>
                        编辑商户</h5>
                </div>
                <div class="widget-content nopadding">
                    <form id="regform" action="/workspace/collegeadmin/modifyBusiness" method="post" name="regform"
                    class="form-horizontal">
                    <div id="tab1">
                    <input type="hidden" name="Id" value="@bModel.Id" />
                    <input type="hidden" name="page" value="@ViewBag.page" />
                        <div class="control-group">
                            <label class="control-label">
                                商户名</label>
                            <div class="controls">
                                <b>@bModel.Name</b></div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                Logo</label>
                            <div class="controls">
                                <input type="hidden" id="photo" name="Logo" value="@bModel.Logo" />
                                    <img style="width: 100px; height: 100px;" id="mainphoto" alt="@bModel.Name" src="@bModel.Logo"  /><br />     
                                            <div id="swfupload-control">
                                    <div>
                                        <input type="button" id="btnsltphoto" />
                                    </div>
                                </div>
                                </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                联系人</label>
                            <div class="controls">
                                <input type="text" placeholder="输入联系人" name="ContactPeople" value="@bModel.ContactPeople" class="span4 {required:true} "
                                    style="width: 200px" />
                                    <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                联系方式</label>
                            <div class="controls">
                                <input type="text" placeholder="输入联系电话" name="ContactInfo" value="@bModel.ContactInfo" class="span4 {required:true,number:true,minlength:11,maxlength:11} " style="width: 200px" />
                            <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                            </div>
                        </div>                        
                    <div class="control-group">
                            <label class="control-label">
                                主营</label>
                            <div class="controls">
                                <input type="text" placeholder="请输入您主营菜品" name="MainSell"  value="@bModel.MainSell" style="width: 600px"
                                    class="span4 " />
                            </div>
                        </div>
                       
                       
                         <div class="control-group">
                          <table border="0">
                          @{
                              string[] startTimeArr = bModel.DeliveryTime.Split('|');
                              string[] endTimeArr = bModel.DeliveryTimeEnd.Split('|');

                              if (startTimeArr != null && startTimeArr.Length != 0)
                              {
                                  for (int i = 0; i < startTimeArr.Length; i++)
                                  {
                                      if (i == 0)
                                      {
                                  
                            <tr>
                                    <td valign="top" width="50%">
                                        <div class="control-group">
                                            <label class="control-label">
                                                <a href="javascript:;" class="addVer">[+]</a> 起始时间</label>
                                            <div class="controls">
                                                <input type="text" style="width: 120px"  name="StartTime" value="@startTimeArr[i]" placeholder="输入起始时间" onFocus="WdatePicker({isShowClear:true,readOnly:true,dateFmt:'HH:mm'})"  class="Wdate {required:true} "/>
                                                <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                            </div>
                                        </div>
                                    </td>
                                    <td valign="top" width="50%">
                                        <div class="control-group">
                                            <label class="control-label">
                                                结束时间</label>
                                            <div class="controls" style="vertical-align: top">
                                                <input type="text" style="width: 120px" name="EndTime" value="@endTimeArr[i]" placeholder="输入结束时间" onFocus="WdatePicker({isShowClear:true,readOnly:true,dateFmt:'HH:mm'})"  class="Wdate {required:true}" />
                                                <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                      }
                                      else
                                      {
                                       <tr>
                                    <td valign="top" width="50%">
                                        <div class="control-group">
                                            <label class="control-label">
                                                 <a href="javascript:;" class="removeVer">[-]</a> 起始时间</label>
                                            <div class="controls">
                                                <input type="text" style="width: 120px"  name="StartTime" value="@startTimeArr[i]" placeholder="输入起始时间" onFocus="WdatePicker({isShowClear:true,readOnly:true,dateFmt:'HH:mm'})"  class="Wdate {required:true} "/>
                                                <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                            </div>
                                        </div>
                                    </td>
                                    <td valign="top" width="50%">
                                        <div class="control-group">
                                            <label class="control-label">
                                                结束时间</label>
                                            <div class="controls" style="vertical-align: top">
                                                <input type="text" style="width: 120px" name="EndTime" value="@endTimeArr[i]" placeholder="输入结束时间" onFocus="WdatePicker({isShowClear:true,readOnly:true,dateFmt:'HH:mm'})"  class="Wdate {required:true}" />
                                                <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                      
                                      }
                                  }
                              }
                              else
                              {
                              <tr>
                                    <td valign="top" width="50%">
                                        <div class="control-group">
                                            <label class="control-label">
                                                <a href="javascript:;" class="addVer">[+]</a> 起始时间</label>
                                            <div class="controls">
                                                <input type="text" style="width: 120px"  name="StartTime" placeholder="输入起始时间" onFocus="WdatePicker({isShowClear:true,readOnly:true,dateFmt:'HH:mm'})"  class="Wdate {required:true} "/>
                                                <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                            </div>
                                        </div>
                                    </td>
                                    <td valign="top" width="50%">
                                        <div class="control-group">
                                            <label class="control-label">
                                                结束时间</label>
                                            <div class="controls" style="vertical-align: top">
                                                <input type="text" style="width: 120px" name="EndTime" placeholder="输入结束时间" onFocus="WdatePicker({isShowClear:true,readOnly:true,dateFmt:'HH:mm'})"  class="Wdate {required:true}" />
                                                <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                              }
                              }
                            </table>
                        </div>
                            
                        <div class="control-group">
                            <label class="control-label">
                                地  址</label>
                            <div class="controls">
                                <input type="text" placeholder="请输入您所在的地址" value="@bModel.Address" name="Address" style="width: 600px"
                                    class="span4 {required:true}" /> <span style="color:Red;font-size:20px">&nbsp;&nbsp;*</span>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">
                                特色菜</label>
                            <div class="controls">
                                <input type="text" placeholder="请输入您的特色菜" name="SpecialFood" value="@bModel.SpecialFood" style="width: 600px"
                                    class="span4" />
                            </div>
                        </div>
                       
                        @{
                            if (ViewBag.Error != null)
                            {
                                if (ViewBag.Error == "")
                                { 
                            <div class="alert alert-success">
                                <strong style="width: 50%; margin: 0px auto">操作成功！</strong></div>
                                }
                                else
                                {
                            <div class="alert alert-error">
                                <strong style="width: 50%; margin: 0px auto">@ViewBag.Error</strong></div>
                                }
                            }
                        }
                        <div class="form-actions">
                            <button type="submit" class="btn btn-primary" onclick="return validateLogo()">
                                保存</button>
                        </div>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

@section tail{
   
<script type="text/javascript" src="/scripts/jquery.js"></script>
<script type="text/javascript" src="/Scripts/plug.js"></script>
<script type="text/javascript" src="/scripts/swfupload/swfupload.js"></script>
<script type="text/javascript" src="/scripts/swfupload/jquery.swfupload.js"></script>
<script type="text/javascript" src="/Scripts/jquery.validate.js"></script>
<script type="text/javascript" src="/Scripts/jquery.metadata.js"></script>

<script type="text/javascript">
    var validation = new plug.BindValidCode();
    $(function () {
        $('#swfupload-control').swfupload({
            upload_url: "/collegeadmin/SWFPrepareUpload",
            file_size_limit: "7 MB",
            file_types: "*.jpg;*.png",
            file_types_description: "Web Image Files",
            file_upload_limit: 0,
            flash_url: "/scripts/swfupload/swfupload.swf",
            button_image_url: '/scripts/swfupload/updatePhotoBtn_01.png',
            button_width: 86,
            button_height: 31,
            button_placeholder: $('#btnsltphoto')[0],
            button_action: SWFUpload.BUTTON_ACTION.SELECT_FILE
        })
                .bind('fileQueued', function (event, file) {
                    $(this).swfupload('startUpload');
                })
                .bind('uploadStart', function (event) {
                    $('#mainphoto').attr('src', '/content/img/loading_big.gif');
                })
                .bind('fileQueueError', function (event, file, errorCode, message) {
                    alert(message);
                    $('#mainphoto').attr('src', photo);
                    //$('#log').append('<li>File queue error - ' + message + '</li>');
                })
                .bind('uploadComplete', function (event, file) {
                    $(this).swfupload('startUpload');
                })
                .bind('uploadSuccess', function (event, file, serverData) {
                    var path = eval('(' + serverData + ')').path;
                    $('#mainphoto').attr('src', path);
                    $('#photo').val(path);
                });


        validation.BindValidator();
        $('#regform').validate({
            errorClass: "help-inline",
            errorElement: "span",
            highlight: function (element, errorClass, validClass) {
                $(element).parents('.control-group').addClass('error');
            },
            unhighlight: function (element, errorClass, validClass) {
                $(element).parents('.control-group').removeClass('error');
            }
        });

        $('.addVer').live('click', function () {

            str = $(this).parent().parent().parent().parent().html();
            //alert(str);
            str = str.replace('addVer', 'removeVer');
            str = str.replace('[+]', '[-]');
            //str = str.replace(/goodspackage/g, 'goodspackage' + rand); //正则表达式替换多个
            $(this).parent().parent().parent().parent().parent().append('<tr>' + str + '</tr>');

        });
        $('.removeVer').live('click', function () {
            $(this).parent().parent().parent().parent().remove();
            return false;
        });
        $('#likBusiness').addClass('open');
        $('#likBusiness').addClass('active');
    });

    function validateLogo() {
        if ($('#photo').val() == '') {
            alert('请添加logo图片！');
            return false;
        }
        return true;
    }
    </script>
}
